Can this be done in 1 line? [PHP]
Posted
by Angelo
on Stack Overflow
See other posts from Stack Overflow
or by Angelo
Published on 2010-06-07T23:05:20Z
Indexed on
2010/06/07
23:12 UTC
Read the original article
Hit count: 169
Can this be done in 1 line with PHP?
Would be awesome if it could:
$out = array("foo","bar");
echo $out[0];
Something such as:
echo array("foo","bar")[0];
Unfortunately that's not possible. Would it be possible like this?
So I can do this for example in 1 line:
echo array(rand(1,100), rand(1000,2000))[rand(0,1)];
© Stack Overflow or respective owner